package org.tloss.web.editor.form.editors.command;

import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.model.IWorkbenchAdapter;
import org.tloss.web.editor.utils.Constants;

public class CommandRootElement implements IWorkbenchAdapter, IAdaptable {
	private BodyCommandElement element;
	private Object[] children;

	public CommandRootElement(BodyCommandElement element) {
		this.element = element;
		element.setParent(this);
		children = new Object[] { element };
	}

	@SuppressWarnings("rawtypes")
	@Override
	public Object getAdapter(Class adapter) {
		if (adapter == IWorkbenchAdapter.class)
			return this;
		return null;
	}

	@Override
	public Object[] getChildren(Object arg0) {

		return children;
	}

	@Override
	public ImageDescriptor getImageDescriptor(Object arg0) {
		return Constants.RUNSCRIPT_DESCRIPTOR;
	}

	@Override
	public String getLabel(Object arg0) {
		return element.getLabel(arg0);
	}

	@Override
	public Object getParent(Object arg0) {
		return null;
	}

}
